<script type="text/javascript">

    var qn = new Array();
    var ans = new Array();
    var sol = new Array();
    var i = 0;
    var j = 0;


    AddQnAToArray = function () {



        var qnaDivId = 'qID';

        qn[i] = document.getElementById("question").value + '###';
        document.getElementById("question").value="";
        ans[i] = document.getElementById("answer").value + '###';
        document.getElementById("answer").value="";

        i++;

        document.getElementById("qnArray").value=qn;
        document.getElementById("ansArray").value=ans;

        showHideCommon(qnaDivId);

        var qtID = document.getElementById("qnatID");
        var qnaTdID = document.getElementById("qnaTdID");
        var newTr1 = document.createElement("tr");
        var divIdName1 = 'qnatr'+i;

        newTr1.setAttribute('id',divIdName1);
        var str1 = qn[i-1];
        var str2 = ans[i-1];
        str1 = str1.replace(/\###/g,"");
        str2 = str2.replace(/\###/g,"");
        newTr1.innerHTML = '<table><tr colspan="2"><td>Qns '+i+': </td><td>'+str1+'</td></tr><tr><td>Ans '+i+': </td><td >'+str2+'</td></tr></table>';

        qtID.appendChild(newTr1);
        qnaTdID.appendChild(qtID);



    }

    AddSolToArray = function () {

        var solDivId = 'sID';

        sol[j] = document.getElementById("solution").value + '###';
        document.getElementById("solution").value="";

        j++;

        document.getElementById("solArray").value=sol;

        showHideCommon(solDivId);

        var stID = document.getElementById("soltID");
        var solTdID = document.getElementById("solTdID");
        var newTr2 = document.createElement("tr");
        var divIdName2 = 'soltr'+j;

        newTr2.setAttribute('id',divIdName2);
        var str3 = sol[j-1];
        str3 = str3.replace(/\###/g,"");
        newTr2.innerHTML = '<table><tr colspan="2"><td>Solution '+j+': </td><td>'+str3+'</td></tr></table>';

        stID.appendChild(newTr2);
        solTdID.appendChild(stID);



    }


skb_api = {

loadPage: function(pageName){
//            var path='';
//            if (typeof parameters != 'undefined' ){
//                var temp = parameters.substring(parameters.indexOf("path=")+5);
//                path = temp.substring(0,temp.indexOf(','));
//            }

            var pageURL= 'skb_home_ajaxprocessor.jsp';
            if(pageName == 'home'){
                pageURL= 'skb_home_ajaxprocessor.jsp';
            } else if (pageName == 'add'){
                pageURL = 'skb_add_ajaxprocessor.jsp';
            } else if (pageName == 'browse'){
                pageURL = 'skb_browse_ajaxprocessor.jsp';
            }

            new Ajax.Request(pageURL,
              {
                method:'get',
                onSuccess: function(transport){
                  var response = transport.responseText || "no response text";
                  document.getElementById("middleDiv").innerHTML = response;
                },
                onFailure: function(){ alert('Something went wrong...') }
              });
        }

};

ChangeLocation = function(par) {
    alert('ced');
    window.location.href = "\'"+par+"\'";
}

</script>